home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / ld / RCS / ld_front.c,v < prev   
Encoding:
Text File  |  1990-10-25  |  3.3 KB  |  166 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    rab:1.2; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     90.08.06.21.07.08;  author rab;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     90.07.24.22.04.12;  author rab;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @Added symm.
  27. @
  28. text
  29. @/* 
  30.  * ld_front.c --
  31.  *
  32.  *    Front end for loader.
  33.  *
  34.  * Copyright 1989 Regents of the University of California
  35.  * Permission to use, copy, modify, and distribute this
  36.  * software and its documentation for any purpose and without
  37.  * fee is hereby granted, provided that the above copyright
  38.  * notice appear in all copies.  The University of California
  39.  * makes no representations about the suitability of this
  40.  * software for any purpose.  It is provided "as is" without
  41.  * express or implied warranty.
  42.  */
  43.  
  44. #ifndef lint
  45. static char rcsid[] = "$Header: /sprite/src/cmds/ld/RCS/ld_front.c,v 1.1 90/07/24 22:04:12 rab Exp Locker: rab $";
  46. #endif /* not lint */
  47.  
  48. #include <stdio.h>
  49. #include <string.h>
  50. #include <stdlib.h>
  51. #include <sys/param.h>
  52. #include <assert.h>
  53. #ifndef __STDC__
  54. #define const
  55. #endif
  56.  
  57. #ifndef EXIT_FAILURE
  58. #define EXIT_FAILURE    1
  59. #endif
  60.  
  61. #ifdef sun3
  62. static const char *hostMachine = "sun3";
  63. #else
  64. #ifdef sun4
  65. static const char *hostMachine = "sun4";
  66. #else
  67. #ifdef ds3100
  68. static const char *hostMachine = "ds3100";
  69. #else
  70. #ifdef symm
  71. static const char *hostMachine = "symm";
  72. #else
  73. NO DEFAULT TARGET MACHINE TYPE DEFINED
  74. #endif
  75. #endif
  76. #endif
  77. #endif
  78.  
  79. /*
  80.  *----------------------------------------------------------------------
  81.  *
  82.  * main --
  83.  *      Search through the command line arguments looking for an argument
  84.  *      of the form -mfoo, where `foo' is a machine type.  If found, delete
  85.  *      it from the list of arguments, and use it to determine which
  86.  *      backend to exec.  If there is no -m then default to the type
  87.  *      of the host machine.
  88.  *
  89.  * Results:
  90.  *    None.
  91.  *
  92.  * Side effects:
  93.  *    Execs machine dependent loader backend.
  94.  *
  95.  *----------------------------------------------------------------------
  96.  */
  97.  
  98. void
  99. main(argc, argv)
  100.     int argc;
  101.     char **argv;
  102. {
  103.     extern int errno;
  104.     int i;
  105.     int j;
  106.     const char *targetMachine;
  107.     char path[MAXPATHLEN];
  108.  
  109.     targetMachine = hostMachine;
  110.     for (i = 1; i < argc; ++i) {
  111.     if (argv[i][0] == '-' && argv[i][1] == 'm') {
  112.         if (argv[i][2] == '\0') {
  113.         targetMachine = argv[i + 1];
  114.         if (targetMachine == NULL) {
  115.             (void) fprintf(stderr, "No target machine specified\n");
  116.             exit(EXIT_FAILURE);
  117.         }
  118.         for (j = i; j < argc - 1; ++j) {
  119.             argv[j] = argv[j + 2];
  120.         }
  121.         argc -= 2;
  122.         assert(argv[argc] == NULL);
  123.         } else {
  124.         targetMachine = argv[i] + 2;
  125.         for (j = i; j < argc; ++j) {
  126.             argv[j] = argv[j + 1];
  127.         }
  128.         --argc;
  129.         assert(argv[argc] == NULL);
  130.         }
  131.         break;
  132.     }
  133.     }
  134.     (void) sprintf(path,
  135.     "/sprite/lib/gcc/%s.md/ld.%s", hostMachine, targetMachine);
  136.     (void) execv(path, argv);
  137.     (void) fprintf(stderr, "Can't exec ``%s'': %s\n", path, strerror(errno));
  138.     exit(EXIT_FAILURE);
  139. }
  140.  
  141. @
  142.  
  143.  
  144. 1.1
  145. log
  146. @Initial revision
  147. @
  148. text
  149. @d17 1
  150. a17 1
  151. static char rcsid[] = "$Header$";
  152. d42 3
  153. d49 1
  154. d65 1
  155. a65 1
  156.  *    Execs machine assembler backend.
  157. d87 1
  158. a87 1
  159.             fprintf(stderr, "No target machine specified\n");
  160. d106 4
  161. a109 3
  162.     sprintf(path, "/sprite/lib/gcc/%s.md/ld.%s", hostMachine, targetMachine);
  163.     execv(path, argv);
  164.     fprintf(stderr, "Can't exec ``%s'': %s\n", path, strerror(errno));
  165. @
  166.